Repository navigation
Conversation
Adds parseUnsignedLong / parseLong / parseInt overloads to LongStringUtils that take the range [start, end) of a CharSequence and give the same result, or NumberFormatException, as their String counterparts on the same chars (Java 8 has no range-based CharSequence overloads of Long.parseLong / Integer.parseInt). They let a header value be parsed in place, from a view, without making a String first. parseUnsignedLong(String) now shares its 19-20 digit path with the range overload. LongStringUtilsRangeTest compares outcomes with the String parsers on edge cases (signs, Unicode digits, every length boundary, overflow) and on random input. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 21, 2026
This comment has been minimized.
This comment has been minimized.
This was referenced Nov 21, 2026
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Adds range-based
CharSequenceoverloads toLongStringUtils(an internal utility in dd-trace-api):parseUnsignedLong(CharSequence, start, end),parseLong(CharSequence, start, end)andparseInt(CharSequence, start, end). Each gives the same result, orNumberFormatException, as itsStringcounterpart on the same chars. No callers yet.Motivation
Part 1 of letting propagation parse header values in place. A Kafka consumer profile shows the header value
Strings as the tracer's largest allocation site; several of them (x-datadog-trace-id,x-datadog-parent-id,x-datadog-sampling-priority) are parsed into numbers and never kept. Parsing them from a view of the record's bytes needs number parsers that take aCharSequencerange, which Java 8 doesn't have (Long.parseLong(CharSequence, int, int, int)and itsIntegercounterpart are Java 9+).The parts, each its own PR:
CharSequencerange parsers.Additional Notes
parseLongandparseIntfollow the JDK's own algorithms for base 10 (optional+/-,Character.digit, accumulating negatively to detect overflow exactly), applied to the range.parseUnsignedLong(CharSequence, ...)mirrorsparseUnsignedLong(String):parseLongup to 18 chars, and the existing 19–20 digit unsigned path, now shared by both overloads (parseLongUnsignedDigits). TheStringoverload's results are unchanged.LongStringUtilsRangeTestcompares each overload's outcome with itsStringcounterpart (Long.parseLong,Integer.parseInt,parseUnsignedLong(String)) on the range of a largerStringBuilder: edge cases (empty, lone signs,+/-prefixes, spaces, letters, Unicode digits, every length boundary, signed and unsigned overflow), 50,000 random strings, and 20,000 random numbers of every magnitude.🤖 Generated with Claude Code